import { configureStore } from '@reduxjs/toolkit'
import counterReducer from './modules/counter'
import type { TypedUseSelectorHook } from 'react-redux'
import { useSelector, useDispatch, shallowEqual } from 'react-redux'
import recommendReducer from '../views/discover/c-page/recommend/store/recommend'
import songsReducer from '../views/discover/c-page/songs/store/songs'
import djRadioReducer from '../views/discover/c-page/djradio/store/djradio'
import artistReducer from '../views/discover/c-page/artist/store/artist'
import albumReducer from '../views/discover/c-page/album/store/album'
import rankingReducer from '../views/discover/c-page/ranking/store/ranking'
import playerReducer from '../views/player/store/player'
import loginReducer from '../views/login/store/login'




const store = configureStore({
  reducer: {
    counter: counterReducer,
    recommend: recommendReducer,
    songs: songsReducer,
    djradio: djRadioReducer,
    artist: artistReducer,
    album: albumReducer,
    ranking: rankingReducer,
    player: playerReducer,
    login: loginReducer
  }
})

type Rootstate = ReturnType<typeof store.getState>
type AppDispatch = typeof store.dispatch



export type RootState = ReturnType<typeof store.getState>
export const useAppSelector: TypedUseSelectorHook<Rootstate> = useSelector
export const useAppDispatch: () => AppDispatch = useDispatch
export const shallowEqualApp = shallowEqual

export default store
